package net.lab1024.sa.admin.module.business.marker.controller;

import net.lab1024.sa.admin.module.business.marker.domain.form.MarkerAddForm;
import net.lab1024.sa.admin.module.business.marker.domain.form.MarkerQueryForm;
import net.lab1024.sa.admin.module.business.marker.domain.form.MarkerUpdateForm;
import net.lab1024.sa.admin.module.business.marker.domain.vo.MarkerVO;
import net.lab1024.sa.admin.module.business.marker.service.MarkerService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 图标地点 Controller
 *
 * @Author 骆伟林
 * @Date 2025-10-27 11:46:41
 * @Copyright 软件需求工程第八组
 */

@RestController
@Tag(name = "图标地点")
public class MarkerController {

    @Resource
    private MarkerService markerService;

    @Operation(summary = "分页查询 @author 骆伟林")
    @PostMapping("/marker/queryPage")
    @SaCheckPermission("marker:query")
    public ResponseDTO<PageResult<MarkerVO>> queryPage(@RequestBody @Valid MarkerQueryForm queryForm) {
        return ResponseDTO.ok(markerService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 骆伟林")
    @PostMapping("/marker/add")
    @SaCheckPermission("marker:add")
    public ResponseDTO<String> add(@RequestBody @Valid MarkerAddForm addForm) {
        return markerService.add(addForm);
    }

    @Operation(summary = "更新 @author 骆伟林")
    @PostMapping("/marker/update")
    @SaCheckPermission("marker:update")
    public ResponseDTO<String> update(@RequestBody @Valid MarkerUpdateForm updateForm) {
        return markerService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 骆伟林")
    @PostMapping("/marker/batchDelete")
    @SaCheckPermission("marker:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return markerService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 骆伟林")
    @GetMapping("/marker/delete/{markerId}")
    @SaCheckPermission("marker:delete")
    public ResponseDTO<String> batchDelete(@PathVariable String markerId) {
        return markerService.delete(markerId);
    }

    @Operation(summary = "根据地址id获取图标地点详情 @author 骆伟林")
    @GetMapping("/marker/getMarkerListByAddressId/{addressId}")
    @SaCheckPermission("marker:getByid")
    public ResponseDTO<List<MarkerVO>> getMarkerListByAddressId(@PathVariable Long addressId) {
        return ResponseDTO.ok(markerService.getMarkerListByAddressId(addressId));
    }

}
